package org.yelongframework.servlet.http;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import javax.servlet.http.HttpServletResponse;

import org.yelongframework.servlet.ServletResponseSupport;

/**
 * 响应支持
 * 
 * @since 1.0.0
 */
public interface HttpServletResponseSupport extends ServletResponseSupport {

	// ==================================================响应内容==================================================

	/**
	 * 响应文本内容
	 * 
	 * @param response    响应
	 * @param text        内容
	 * @param contentType 内容类型
	 * @throws IOException 响应异常
	 */
	void responseText(HttpServletResponse response, String text, String contentType) throws IOException;

	/**
	 * 响应字节内容
	 * 
	 * @param response 响应
	 * @param content  内容字节流
	 * @throws IOException 响应异常
	 */
	void responseByteArray(HttpServletResponse response, byte[] content) throws IOException;

	// ==================================================响应文件==================================================

	/**
	 * 响应文件
	 * 
	 * @param response 响应
	 * @param file     文件
	 * @throws IOException 响应文件异常
	 */
	void responseFile(HttpServletResponse response, File file) throws IOException;

	/**
	 * 响应文件
	 * 
	 * @param response 响应
	 * @param file     文件
	 * @param fileName 文件名称
	 * @throws IOException 响应文件异常
	 */
	void responseFile(HttpServletResponse response, File file, String fileName) throws IOException;

	/**
	 * 响应文件
	 * 
	 * @param response 响应
	 * @param data     文件流
	 * @param fileName 文件名称
	 * @throws IOException 响应文件异常
	 */
	void responseFile(HttpServletResponse response, byte[] data, String fileName) throws IOException;

	/**
	 * 响应文件
	 * 
	 * @param response    响应
	 * @param inputStream 文件流
	 * @param fileName    文件名称
	 * @throws IOException 响应文件异常
	 */
	void responseFile(HttpServletResponse response, InputStream inputStream, String fileName) throws IOException;

	/**
	 * 响应文件
	 * 
	 * @param response    响应
	 * @param inputStream 文件流
	 * @param bufferSize  缓冲区大小
	 * @param fileName    文件名称
	 * @throws IOException 响应文件异常
	 */
	void responseFile(HttpServletResponse response, InputStream inputStream, int bufferSize, String fileName)
			throws IOException;

}
